package com.example.administrator.pomelostreet.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.administrator.pomelostreet.HttpUtils.Item_list;
import com.example.administrator.pomelostreet.R;

import java.util.List;


/**
 * Created by Administrator on 2017/2/13.
 */

public class MyBaseadapter extends RecyclerView.Adapter<MyBaseadapter.ViewHolder> {

    private List<Item_list>lists;
    private Context context;

    public MyBaseadapter(List<Item_list> lists, Context context) {
        this.lists = lists;
        this.context = context;
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        ImageView picture;
        TextView name;
        TextView vip_picture;
        TextView original_price;
        TextView purchase_btn;

        public ViewHolder(View itemView) {
            super(itemView);
            picture = (ImageView) itemView.findViewById(R.id.picture);
            name = (TextView) itemView.findViewById(R.id.tv_name);
            vip_picture = (TextView) itemView.findViewById(R.id.vip_price);
            original_price = (TextView) itemView.findViewById(R.id.original_price);
            purchase_btn = (TextView) itemView.findViewById(R.id.purchase_btn);

        }
    }


    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
       View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.mybaseadapter,parent,false);
        ViewHolder viewHolder=new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        Item_list item_list = lists.get(position);
        String url = item_list.getPicture();
        Glide.with(context).load(url).into(holder.picture);
        holder.name.setText(item_list.getName());
        holder.original_price.setText(item_list.getOriginal_price());
        holder.purchase_btn.setText(item_list.getPurchase_btn());
        holder.vip_picture.setText(item_list.getVip_price());

    }

    @Override
    public int getItemCount() {
        return lists.size();
    }


}
